//
// Created by xili on 2024/8/5 19:51.
// Go big or go home.
//
#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    bool isFascinating(int n) {
        string s;
        unordered_map<int, int> ump;
        for (int i = 1; i < 4; i++) {
            s += to_string(i * n);
        }
        for (auto &item: s) {
            ump[item - '0']++;
        }
        if (ump.size() != 9 || ump['0'] != 0) {
            return false;
        }
        for (int i = 1; i < 10; i++) {
            if (ump[i] != 1) {
                return false;
            }
        }
        return true;
    }
};